import os

#Get the hypothesis testing result based on the keyword (such as t and pval)
def getHypTestResult(keyword):
    try:
        fid = open('test_results.txt','r')
        s = fid.readlines()

        for line in s:
            term = line.split(':')[0].strip()
            if term == keyword:
                return line.split(':')[1].strip()
        return -1

    except IOError, (errno, strerror):
        print "I/O error(%s): %s" % (errno, strerror)


a = [116,126,123,125,139,141,141,123,136,124]
b = [112,120,118,120,131,133,133,118,128,119,139,95,127,127]
mu1 = 129.4
mu2 = 122.8571
sd1 = 8.9839
sd2 = 10.9745
m = 10
n = 14
type_ = 1
args = str(mu1)+' '+str(mu2)+' '+str(sd1)+' '+str(sd2)+' '+str(m)+' '+str(n)+' '+str(type_)
os.system("two_sample_t_test " + args )

pval = getHypTestResult('pval')
print 'pval: ' + str(pval)

ci = 0.95
if float(pval) > 1-ci:
    print 'Data consistent with the Null Hypothesis.'
else:
    print 'Evidence against the Null Hypothesis in favour with the Alternate Hypothesis.'
